Merge "Add meta=userinfo&uiprop=latestcontrib"
[lhc/web/wiklou.git] / includes / api / ApiBlock.php
index 3581ac8..673fc6b 100644 (file)
@@ -56,26 +56,14 @@ class ApiBlock extends ApiBase {
 
                $editingRestriction = 'sitewide';
                $pageRestrictions = '';
+               $namespaceRestrictions = '';
                if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
-                       if ( $params['pagerestrictions'] ) {
-                               $count = count( $params['pagerestrictions'] );
-                               if ( $count > 10 ) {
-                                       $this->dieWithError(
-                                               $this->msg(
-                                                       'apierror-integeroutofrange-abovebotmax',
-                                                       'pagerestrictions',
-                                                       10,
-                                                       $count
-                                               )
-                                       );
-                               }
-                       }
-
                        if ( $params['partial'] ) {
                                $editingRestriction = 'partial';
                        }
 
-                       $pageRestrictions = implode( "\n", $params['pagerestrictions'] );
+                       $pageRestrictions = implode( "\n", (array)$params['pagerestrictions'] );
+                       $namespaceRestrictions = implode( "\n", (array)$params['namespacerestrictions'] );
                }
 
                if ( $params['userid'] !== null ) {
@@ -133,6 +121,7 @@ class ApiBlock extends ApiBase {
                        'Tags' => $params['tags'],
                        'EditingRestriction' => $editingRestriction,
                        'PageRestrictions' => $pageRestrictions,
+                       'NamespaceRestrictions' => $namespaceRestrictions,
                ];
 
                $retval = SpecialBlock::processForm( $data, $this->getContext() );
@@ -146,7 +135,7 @@ class ApiBlock extends ApiBase {
 
                $block = Block::newFromTarget( $target, null, true );
                if ( $block instanceof Block ) {
-                       $res['expiry'] = ApiResult::formatExpiry( $block->mExpiry, 'infinite' );
+                       $res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
                        $res['id'] = $block->getId();
                } else {
                        # should be unreachable
@@ -166,6 +155,7 @@ class ApiBlock extends ApiBase {
                if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) {
                        $res['partial'] = $params['partial'];
                        $res['pagerestrictions'] = $params['pagerestrictions'];
+                       $res['namespacerestrictions'] = $params['namespacerestrictions'];
                }
 
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
@@ -207,6 +197,12 @@ class ApiBlock extends ApiBase {
                        $params['partial'] = false;
                        $params['pagerestrictions'] = [
                                ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_ISMULTI_LIMIT1 => 10,
+                               ApiBase::PARAM_ISMULTI_LIMIT2 => 10,
+                       ];
+                       $params['namespacerestrictions'] = [
+                               ApiBase::PARAM_ISMULTI => true,
+                               ApiBase::PARAM_TYPE => 'namespace',
                        ];
                }